package com.langfeiyes.pattern.composite.v2;


import java.util.function.Consumer;

public class App {

    public static void main(String[] args) {
        Component systemC = new MenuComposite("系统管理", 1);
        Component customerC = new MenuComposite("客户管理", 2);

        Component onlineLeaf = new MenuLeaf("线上客户");
        Component latentLeaf= new MenuLeaf("潜在客户");

        Component siteLeaf = new MenuLeaf("公司官网");
        Component publicLeaf = new MenuLeaf("公共管理");

        customerC.addChild(onlineLeaf);
        customerC.addChild(latentLeaf);

        systemC.addChild(customerC);
        systemC.addChild(siteLeaf);
        systemC.addChild(publicLeaf);


        systemC.print();












        method("dafei", name-> System.out.println(name));

        method("dafei", name-> System.out.println(name), name-> System.err.println(name));
    }

    public static void method(String a, Consumer<String> cs){
        cs.accept(a);
    }

    public static void method(String a, Consumer<String> cs1, Consumer<String> cs2){
        cs1.andThen(cs2).accept(a);
    }


}
